package org.filetransfer.file_transfer_java_backend.config;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.SerializationFeature;
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@Configuration
public class JacksonConfig {
    @Bean
    public ObjectMapper objectMapper() {
        ObjectMapper objectMapper = new ObjectMapper();
        objectMapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);

        // Register JavaTimeModule to handle Java 8 Date & Time types like Instant
        objectMapper.registerModule(new JavaTimeModule());

        // Explicitly disable writing dates as timestamps to ensure ISO-8601 string format
        // JavaTimeModule generally defaults to this, but being explicit can prevent issues.
        objectMapper.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS);

        // You can still call findAndRegisterModules() if you rely on it for other modules,
        // though JavaTimeModule is now explicitly registered.
        objectMapper.findAndRegisterModules();

        return objectMapper;
    }
}